<html>
    <meta charset="utf-8">
    <body>
<?php
  $student_name=$_POST['stname']; 
  $student_identity_number=$_POST['idcard']; 
  $student_exam_number=$_POST['stuid'];
  $openid= $_POST['wxid'];
  $link=mysqli_connect(SAE_MYSQL_HOST_M.':'.SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS);
  mysqli_select_db($link,"app_formtest1");
  if (!$link)
  {
	die('Could not connect: ' . mysql_error());
  };

  $result=mysqli_query($link,"select * from weixin_students where student_identity_number=$student_identity_number");
 
  $l=mysqli_num_rows($result);

  if($l){
  	 $row=mysqli_fetch_object($result);
     $name= $row->student_name;
     $exam_number= $row->student_exam_number;
     $identity_number= $row->student_identity_number;
     
     echo "学生姓名：".$student_name."<br>";
     echo "准考证号：".$student_exam_number."<br>";
     echo "身份证号：".$student_identity_number."<br>";

$kv = new SaeKV();
// 初始化KVClient对象
$ret = $kv->init();
      $key = $_POST['wxid'];
      $myinfo = $student_name;
      $kv->set($key,$myinfo);//将我的信息的数组写到KVDB中
//然后再取出来
$myinfo_inkvdb = $kv->get($key);
      //var_dump($myinfo_inkvdb);
     $rt=mysqli_query($link,"update weixin_students set student_weixin_id = '$openid' where student_identity_number=$student_identity_number") or die(mysql_error());  

      echo "<br><h3>绑定成功</h3>";
  }
   else{
       echo "<h3>无此考生</h3>";

  };

mysqli_close($link);
?>
    </body>
</html>